package wang.unclecat.aar2jar


final class ByteStreams {
  private static final int BUFFER_SIZE = 8192

  private static byte[] createBuffer() {
    return new byte[BUFFER_SIZE]
  }

  static long copy(InputStream from, OutputStream to) throws IOException {

    byte[] buf = createBuffer()
    long total = 0
    while (true) {
      int r = from.read(buf)
      if (r == -1) {
        break
      }
      to.write(buf, 0, r)
      total += r
    }
    return total
  }
}
